package one;

public class A013 {


    public static void main(String[] args) {
       int[] a = {5,4,-1,7,8};
       //maxSubArray(a);
    }


    public int maxSubArray(int[] nums) {
        int n = nums.length;
        int[] dp = new int[n];
        int ret=dp[0]=nums[0];
        for(int i=1;i<n;i++) {
            dp[i]=Math.max(nums[i],dp[i-1]+nums[i]);
            ret=Math.max(ret,dp[i]);
        }
        return ret;
    }
}
